﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace FootBallMatchProject.Piography.Client
{
    public partial class NationalTeamInfoForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataClassLayer.NationalTeam nationalteam = new DataClassLayer.NationalTeam();
            if (Request.QueryString["ID"] != null &&
                Request.QueryString["ID"].ToString() != "")
            {
                nationalteam.ID = int.Parse(Request.QueryString["ID"].ToString());
            }
            else
            {
                nationalteam.ID = 1;
            }
            DataClassLayer.NationalTeamCollection nationalteams = new DataClassLayer.NationalTeamCollection();
            DataTable table = nationalteams.FillList(nationalteam);
            if (table.Rows.Count == 1)
            {
                NationalTeamView.DataSource = table;
                NationalTeamView.DataBind();
            }
            DataClassLayer.NationalStatistic nationalstatistic = new DataClassLayer.NationalStatistic();
            DataClassLayer.NationalStatisticCollection nationalstatistics = new DataClassLayer.NationalStatisticCollection();
            if (Request.QueryString["ID"] != null &&
                Request.QueryString["ID"].ToString() != "")
            {
                nationalstatistic.NationalTeamID = int.Parse(Request.QueryString["ID"].ToString());
            }
            else
            {
                nationalstatistic.NationalTeamID = 1;
            }
            nationalstatistic.Year = DateTime.Now.Year;
            DataTable statistictable = nationalstatistics.FillList(nationalstatistic);
            if (statistictable.Rows.Count > 0)
            {
                ((DataList)NationalTeamView.FindControl("StatisticsList")).DataSource = statistictable;
                ((DataList)NationalTeamView.FindControl("StatisticsList")).DataBind();
            }
            DataTable playertable = nationalteams.FillListPlayers(nationalteam);
            if (playertable.Rows.Count > 0)
            {
                ((DataList)NationalTeamView.FindControl("PlayerList")).DataSource = playertable;
                ((DataList)NationalTeamView.FindControl("PlayerList")).DataBind();
            }
        }
    }
}